#define _CRT_SECURE_NO_WARNINGS 1


/*class Solution
{
public:
    int totalFruit(vector<int>& fruits)
    {
        int n = fruits.size();
        vector<int> hash(n + 1);
        int ret = 0;
        for (int left = 0, right = 0, kinds = 0; right < n; right++)
        {
            int in = fruits[right];
            if (hash[in] == 0)
            {
                kinds++;
            }
            hash[in]++;

            while (kinds > 2)
            {
                int out = fruits[left];
                hash[out]--;
                if (hash[out] == 0)
                {
                    kinds--;
                }
                left++;
            }

            ret = max(ret, right - left + 1);
        }

        return ret;
    }
};*/